//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package 力扣.题库.未分类.demo60AND80;

public class demo76 {
    public demo76() {
    }

    public static void main(String[] args) {
        System.out.println(minWindow("bbaac", "aba"));
    }

    public static String minWindow(String s, String t) {
        int l = 0;
        int r = 0;
        int staty = 0;
        int end = 0;

        for(int i = 0; i < s.length(); ++i) {
            StringBuilder sb = new StringBuilder(t);
            if (sb.indexOf(String.valueOf(s.charAt(i))) != -1) {
                sb.deleteCharAt(sb.indexOf(String.valueOf(s.charAt(i))));

                for(r = i + 1; r < s.length() && !sb.isEmpty(); ++r) {
                    if (sb.indexOf(String.valueOf(s.charAt(r))) != -1) {
                        sb.deleteCharAt(sb.indexOf(String.valueOf(s.charAt(r))));
                    }
                }

                if (!sb.isEmpty() || r != s.length() || end - staty <= r - i + 1 && end != 0) {
                    if (sb.isEmpty() && (end - staty > r - i || end == 0)) {
                        staty = i;
                        end = r;
                    }
                } else {
                    staty = i;
                    end = r;
                }
            }
        }

        return s.substring(staty, end);
    }
}
